# 定义蓝图
from flask import Blueprint
from flask_restplus import Api
from common.utils import constants

# from common.utils.output_json import output_json
from .hello.hello_views import HelloWord
from .hello.hello_views import hello_ns
from .user.views import user_ns
from .user.views import UserLoginView
from app import app_shop

# 生成蓝图对象
bp = Blueprint("hello_word", __name__, url_prefix=constants.BASE_URL_PREFIX)
# 生成Api对象
api = Api(bp, title="基于flask的商城系统", description="flask-shop", doc="/docs")

if not app_shop.config["DEBUG"]:
    api = Api(app_shop)

# 添加名字空间
api.add_namespace(hello_ns)
api.add_namespace(user_ns)


# 注册路由
hello_ns.add_resource(HelloWord, "/word")
user_ns.add_resource(UserLoginView, "/login")
# 设置返回json格式
# hello_api.representation("application/json")(output_json)
# 注册蓝图
